package com.example.tests;

import static org.testng.Assert.assertEquals;
import java.util.Collections;
import java.util.List;
import org.testng.annotations.Test;

public class GroupCreationTests extends TestBase {

  @Test(dataProvider = "randomValidGroupGenerator")
  public void testGroupCreationWithValidData(GroupData group) throws Exception {
    app.getNavigationHelper().openMainPage();
    app.getNavigationHelper().gotoGroupsPage();
    
    // save old state
    List<GroupData> oldlist = app.getGroupHelper().getGroups();
    
    //actions
    app.getGroupHelper().initGroupCreation();
    app.getGroupHelper().fillFormGroupCreation(group);
    app.getGroupHelper().submitGroupCreation();
    app.getGroupHelper().returnToGroupsCreation();
  	
    //save new state
    List<GroupData> newlist = app.getGroupHelper().getGroups();
  
  	// compare states
    oldlist.add(group);
    Collections.sort(oldlist);
    assertEquals(oldlist, newlist);
  	} 
}
  

